<template>
  <div
    class="main-page"
    style="min-width:1366px;"
  >
    <el-form ref="form">
      <!-- 搜索栏 -->
      <BaseSearchBar v-on:ChildSearchEvent="getSearchOperationList"></BaseSearchBar>
    </el-form>
    <!-- 表单 -->
    <el-card
      :body-style="{ padding: '0px' }"
      class="box-card"
    >
      <!-- <div class="SearchT">
        <div class="tableLable">数据管理列表</div>
        <el-button type="danger" class="BatchDeleBtn" style="width:80px" size="small">批量删除</el-button>

        <el-button type="primary" class="exportBtn" style="width:80px" size="small">导出</el-button>
      </div> -->
      <div class="tableStyle">
        <el-table
          ref="multipleTable"
          class="card-table"
          :data="OperationList"
          tooltip-effect="dark"
          style="font-size:12px"
          :header-cell-style="{ background: '#3F9DFD', color: '#FFF' }"
          size="medium"
          height="634px"
          stripe
          border
        >
          <el-table-column
            label="序号"
            type="index"
            width="50"
          ></el-table-column>

          <el-table-column
            prop="ssdm"
            label="医院手术编码"
            show-overflow-tooltip
            width="120"
          />
          <el-table-column
            prop="ssmc"
            label="医院手术名称"
            show-overflow-tooltip
            width="500"
          />
          <el-table-column
            label="同步时间"
            show-overflow-tooltip
          >
            <template slot-scope="scope">{{getDate(scope.row.insTime)}}</template>
          </el-table-column>
        </el-table>
        <div class="block">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="queryInfo.pagenum"
            :page-sizes="[20, 50, 100]"
            :page-size="queryInfo.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
          ></el-pagination>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import BaseSearchBar from "./BaseSearchBar";
import { getOperationList, getdate } from "@/api/rad";
export default {
  name: "MainPage",
  components: {
    BaseSearchBar
  },
  methods: {
    // 监听pagesize改变的事件
    handleSizeChange(newSize) {
      console.log(newSize);
    },
    // 当前展示的页面
    handleCurrentChange(newPage) {
      console.log(newPage);
    }
  },
  data() {
    return {
      // 列表的参数对象
      queryInfo: {
        ssdm: "",
        ssmc: "",
        // 当前的页数
        page: 1,
        // 当前页显示多少数据
        pageSize: 20
      },
      OperationList: [],
      total: 0
    };
  },
  created: function() {
    this.getOperationList();
  },
  methods: {
    // 监听pagesize改变的事件
    handleSizeChange(newSize) {
      this.queryInfo.pageSize = newSize;
      this.getOperationList();
    },
    // 当前展示的页面
    handleCurrentChange(newPage) {
      // console.log(newPage)
      // console.log("handleCurrentChange")
      this.queryInfo.page = newPage;

      this.getOperationList();
    },
    async getOperationList() {
      let _this = this;
      let res = await this.$rad.getOperationList({
        ssdm: _this.queryInfo.ssdm,
        ssmc: _this.queryInfo.ssmc,
        page: _this.queryInfo.page,
        pageSize: _this.queryInfo.pageSize
      });
      this.OperationList = res.rows;
      this.total = res.total;
    },
    getSearchOperationList(data) {
      this.queryInfo.ssdm = data.ssdm;
      this.queryInfo.ssmc = data.ssmc;
      this.getOperationList();
    },
    //时间戳转时间
    getDate(data) {
      return this.$rad.getdate(data);
    }
  }
};
</script>
<style scoped>
.main-page {
  font-size: 12px;
}
.el-card {
  margin-left: 3px;
}
.SearchT {
  display: flex;
  justify-content: flex-end;
  height: 50px;
  align-items: center;
  background-color: #e6edf3;
  font-size: 14px;
}
.tableLable {
  flex: 1;
  text-align: left;
  margin-left: 15px;
  letter-spacing: 2px;
  font-size: 14px;
  color: #32a6f3;
  font-weight: bold;
}
.exportBtn {
  margin-right: 23px;
}
.BatchDeleBtn {
  margin-right: 15px;
}
.tableStyle {
  width: 100%;
  height: 100%;
}
.card-table {
  width: 100%;
  height: 75%;
}
.block {
  text-align: center;
  margin-top: 12px;
  margin-bottom: 12px;
}
</style>
